/*
 *  * Copyright (C) 2021 Huawei Device Co., Ltd.
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 */
package com.yalantis.guillotine.sample.slice;

import com.yalantis.guillotine.animation.GuillotineAnimation;
import com.yalantis.guillotine.sample.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.components.DirectionalLayout;
import ohos.agp.components.LayoutScatter;
import ohos.agp.components.StackLayout;

public class MainAbilitySlice extends AbilitySlice {

    private static final long RIPPLE_DURATION = 250;

    @Override
    public void onStart(Intent intent) {
        super.setUIContent(ResourceTable.Layout_ability_main);
        DirectionalLayout toolbar = (DirectionalLayout) findComponentById(ResourceTable.Id_toolbar);
        StackLayout root = (StackLayout) findComponentById(ResourceTable.Id_root);
        Component contentHamburger = (Component) findComponentById(ResourceTable.Id_content_hamburger);

        Component guillotineMenu = LayoutScatter.getInstance(this).parse(ResourceTable.Layout_guillotine, null, false);
        root.addComponent(guillotineMenu);

        new GuillotineAnimation.GuillotineBuilder(guillotineMenu, guillotineMenu.findComponentById(ResourceTable.Id_guillotine_hamburger), contentHamburger)
                .setStartDelay(RIPPLE_DURATION)
                .setActionBarViewForAnimation(toolbar)
                .setClosedOnStart(true)
                .build();
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
